package com.ivan.toolkit.swing;

import java.awt.Font;

import javax.swing.UIManager;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;

import com.ivan.toolkit.common.Quietly;

public class LookAndFeels {
	
	public static boolean applyNimbus() {
		
		Quietly.run(()->{
			
			UIManager.setLookAndFeel(new NimbusLookAndFeel());
			
			Font font = new Font("微软雅黑", Font.PLAIN, 16);
			
			UIManager.getDefaults()
			.entrySet()
			.forEach(k-> {
				if(k.getKey().toString().endsWith(".font")) {
					UIManager.put(k.getKey(), font);
				}
			});
			
		});
		
		return true;
		
	}
	
	/*
	public static void applyNimbus() throws Exception {
    	UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
    	
    	Font font = new Font("微软雅黑", Font.PLAIN, 12);
    	java.util.Enumeration<?> keys = UIManager.getDefaults().keys();
    	while (keys.hasMoreElements())
    	{
    		Object key = keys.nextElement();
    		
    		Object value = UIManager.get(key);
    		if (value instanceof Font)
    		{
    			UIManager.put(key, font);
    		}
    	}
	}
	*/

}
